package com.xunqi.usercenter.rocketmq;

import com.xunqi.common.dto.user.UserAddBonusMsgDTO;
import com.xunqi.usercenter.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Description: 接收消息
 * @Created with IntelliJ IDEA.
 * @author: 夏沫止水
 * @create: 2020-04-17 15:25
 **/
@Service
@Slf4j
public class AddBonusStreamConsumer {

    @Resource
    private UserService userService;

    /**
     * 用户微服务接收内容中心消息，为用户加积分
     * @param userAddBonusMsgDTO
     */
    @StreamListener(Sink.INPUT)
    public void receive(UserAddBonusMsgDTO userAddBonusMsgDTO) {

        userAddBonusMsgDTO.setEvent("CONTRIBUTE");
        userAddBonusMsgDTO.setDescription("投稿加积分....");
        userService.addBonus(userAddBonusMsgDTO);
    }

}
